import java.util.ArrayList;
import java.util.List;

public class Test8 {

    public static List<Integer> factorize(int n) {
        List<Integer> factors = new ArrayList<>();
        factorizeHelper(n, 2, factors);
        return factors;
    }

    private static void factorizeHelper(int n, int divisor, List<Integer> factors) {
        while (n % divisor == 0) {
            factors.add(divisor);
            n /= divisor;
        }
        if (n > 1) {
            factorizeHelper(n, divisor + 1, factors);
        }
    }

    public static void main(String[] args) {
        int n = 12;
        List<Integer> factors = factorize(n);
        System.out.println("Integer factorization of " + n + ": " + factors);
    }
}
